

** doing figure 1 
** it comes in two parts: I start with the left hand side
** There is then an interlude for the appendix table 1
** then we return to do the right hand side of figure 1. 

use "data/truth_telling_meta_study_merged_data.dta", clear

set scheme plotplain

* keep the three papers only
keep if authors=="Shalvi,Eldar,Bereby-Meyer" |  authors=="Shalvi,Dana,Handgraaf,DeDreu" | authors=="Gino,Ariely"


* translate to a 0-5 distribution
gen roll1=round(2.5+(standardized_report_per_round)*2.5,1)

collapse ( count ) n_treatment=roll1 (mean) roll1 ( sd) roll1_sd=roll1 (semean) roll1_se=roll1, by(treatment control_rolls)

gen treat=0 // need to pair them off
replace treat=1 if treatment==405 | treatment==407
replace treat=2 if treatment==404 | treatment==406
replace treat=3 if treatment==402 | treatment==403
replace treat=4 if treatment==162 | treatment==166
replace treat=5 if treatment==163 | treatment==167
replace treat=6 if treatment==164 | treatment==168
replace treat=7 if treatment==165 | treatment==169

sort treat cont
gen roll1_with = roll1[_n+1]
gen roll1_sd_with = roll1_sd[_n+1]
gen roll1_se_with = roll1_se[_n+1]
gen n_with= n[_n+1]

rename roll1 		roll1_without
rename n_treatment 	n_without
rename roll1_sd 	roll1_sd_without

drop if control_r==1
drop control

gen 	label =  "Shalvi et al (2012): Low Time Pressure"  				if _n==1
replace label =  "Shalvi et al (2012): High Time Pressure"			 	if _n==2
replace label =  "Shalvi et al (2011): Exp 1" 							if _n==3
replace label =  "Gino & Ariely (2012): Exp 3, Creative" 				if _n==4
replace label =  "Gino & Ariely (2012): Exp 4, High Creativity" 		if _n==5
replace label =  "Gino & Ariely (2012): Exp 4, Low Creativity" 			if _n==6
replace label =  "Gino & Ariely (2012): Exp 3, Neutral" 				if _n==7


* declaring it is a metaanlysis
meta esize  n_with roll1_with roll1_sd_with n_without roll1_without roll1_sd_without, studylabel(label)


meta forestplot _id   _plot   _weight  , xline(0)  columnopts(_weight, format(%7.1f)) ///
noohetstats noohomtest noosigtest noghetstats nogwhomtests nogsigtests   nogbhomtests nonotes   ///
 columnopts(_plot, supertitle("Effect Size") title("Multiple vs. Single Rolls")) ///
columnopts(_id,  title("Article"))

graph export "output/figure1a.pdf", as(pdf) name("Graph") replace



*********************
 * RHS
 ********************


meta set  roll1_with roll1_se_with
meta forestplot _plot _weight, xline(2.5 3.96) xlabel(2(.5)4) xtick(2(.5)4) ///
 noohetstats noohomtest noosigtest noghetstats nogwhomtests nogsigtests   nogbhomtests    ///
 columnopts(_plot, supertitle("Mean Claim") title("In Multiple Roll Treatment")) ///
 columnopts(_weight, format(%7.1f)) nonotes
graph export "output/figure1b.pdf", as(pdf) name("Graph") replace

meta summarize, random(ebayes )




*********************
 * Appendix, Table 1 
********************

meta esize  n_with roll1_with roll1_sd_with n_without roll1_without roll1_sd_without, studylabel(label)
meta summarize, random(ebayes )
gen se_with=roll1_sd_with/(n_with^.5)
gen se_without=roll1_sd_without/(n_without^.5)

// appendix table 1. 
list  n_with roll1_with se_with n_without roll1_without se_without _meta_es _meta_se
keep  n_with roll1_with se_with n_without roll1_without se_without _meta_es _meta_se
order n_with roll1_with se_with n_without roll1_without se_without _meta_es _meta_se

format roll1_with se_with roll1_without se_without _meta_es _meta_se %9.3f

texsave using "output/appendixtable1.tex", varlabels hlines(-2) frag replace 



